Source for file SC_SelectSql.php
Documentation is available at SC_SelectSql.php
* This file is part of EC-CUBE
* Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
* http://www.lockon.co.jp/
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
/* ---- SQL文を作るクラス ---- */
function getSql( $mode =
"" ){
// $mode == 1 は limit & offset無し
$return =
"%" .
$return.
"%";
$this->setWhere( $column .
" BETWEEN ? AND ?" );
$return =
array($from, $to);
//-- 期間検索(○年○月○日か~○年○月○日まで)
function selectTermRange($from_year, $from_month, $from_day, $to_year, $to_month, $to_day, $column) {
$date1 =
$from_year .
"/" .
$from_month .
"/" .
$from_day;
// @see http://svn.ec-cube.net/open_trac/ticket/328
// FIXME とりあえずintvalで対策...
// SQL文のdate関数に与えるフォーマットは、yyyy/mm/ddで指定する。
$date2 =
date('Y/m/d', $date2);
if( ( $from_year !=
"" ) &&
( $from_month !=
"" ) &&
( $from_day !=
"" ) &&
( $to_year ==
"" ) &&
( $to_month ==
"" ) &&
( $to_day ==
"" ) ) {
$this->setWhere( $column .
" >= '" .
$date1 .
"'");
if( ( $from_year !=
"" ) &&
( $from_month !=
"" ) &&
( $from_day !=
"" ) &&
( $to_year !=
"" ) &&
( $to_month !=
"" ) &&
( $to_day !=
"" ) ) {
$this->setWhere( $column .
" >= '" .
$date1 .
"' AND ".
$column .
" < date('" .
$date2 .
"')" );
if( ( $from_year ==
"" ) &&
( $from_month ==
"" ) &&
( $from_day ==
"" ) &&
( $to_year !=
"" ) &&
( $to_month !=
"" ) &&
( $to_day !=
"" ) ) {
$this->setWhere( $column .
" < date('" .
$date2 .
"')");
// checkboxなどで同一カラム内で単一、もしくは複数選択肢が有る場合 例: AND ( sex = xxx OR sex = xxx OR sex = xxx ) AND ...
foreach( $arr as $data ) {
if( count( $arr ) >
1 ) {
if( ! is_null( $data ) ) $item .=
$ItemStr .
" = ? OR ";
if( ! is_null( $data ) ) $item =
$ItemStr .
" = ?";
if( count( $arr ) >
1 ) $item =
"( " .
rtrim( $item, " OR " ) .
" )";
$item =
" ${ItemStr} IS NULL ";
foreach( $arr as $data ) {
$item .=
" OR ${ItemStr} = ?";
$item =
" ${ItemStr} IS NULL OR ${ItemStr} = '' ";
foreach( $arr as $data ) {
$item .=
" OR ${ItemStr} = ?";
/* 複数のカラムでORで優先検索する場合 例: AND ( item_flag1 = xxx OR item_flag2 = xxx OR item_flag3 = xxx ) AND ...
if ( $_POST['show_site1'] ) $arrShowsite_1 = array( "column" => "show_site1",
"value" => $_POST['show_site1'] );
$count =
count( $arrWhere );
for( $i =
0; $i <
$count; $i++
) {
if( isset
( $arrWhere[$i]["value"] ) ) $statement .=
$arrWhere[$i]["column"] .
" = " .
SC_Utils_Ex::sfQuoteSmart($arrWhere[$i]["value"]) .
" OR " ;
$statement =
"( " .
rtrim( $statement, " OR " ) .
" )";
$this->where .=
" AND " .
$statement;
$this->where =
"WHERE " .
$statement;
$this->where .=
" AND " .
$where;
$this->where =
"WHERE " .
$where;
$this->order =
"ORDER BY " .
$order;
$this->group =
"GROUP BY " .
$group;
$this->limit =
" LIMIT " .
$limit;
$this->offset =
" OFFSET " .
$offset;
Documentation generated on Tue, 28 Apr 2009 18:13:39 +0900 by phpDocumentor 1.4.2